﻿using System;
using GeoAPI.Geometries;

namespace NetTopologySuite.Algorithm.Locate
{
	public static class PointOnGeometryLocatorExtensions
	{
		public static bool Intersects(IPointOnGeometryLocator locator, Coordinate coordinate)
		{
			if (locator == null)
			{
				throw new System.ArgumentNullException("locator");
			}
			if (coordinate == null)
			{
				throw new System.ArgumentNullException("coordinate");
			}
			switch (locator.Locate(coordinate))
			{
			case Location.Interior:
			case Location.Boundary:
				return true;
			case Location.Exterior:
				return false;
			default:
				throw new InvalidOperationException("IPointOnGeometryLocator.Locate should never return anything other than Boundary, Interior, or Exterior.");
			}
		}
	}
}
